Love Meter
Introduction
How much love π are you emitting today? Create a π LOVE METER π machine with your micro:bit!

Step 1
Add an input ||input:on pin pressed|| function to run code when Pin P0 is pressed on the micro:bit. Type the code below, or drag a code snippet from the ||input:Input|| Toolbox category.
input.onPinPressed(TouchPin.P0, function() {
})
Step 2
Write some code to show a number in the ||input:on pin pressed|| function, using the basic ||basic:show number|| function.
input.onPinPressed(TouchPin.P0, function() {
basic.showNumber(0)
})
Step 3
Instead of showing 0, use the ||math:randint|| function to show a random number between a minimum and maximum value.
input.onPinPressed(TouchPin.P0, function() {
basic.showNumber(randint(0, 10))
})
Step 4
Everyone knows that love can be measured on a scale of 0 to 100. So, in the ||math:randint|| function, change the maximum value to 100.
input.onPinPressed(TouchPin.P0, function() {
basic.showNumber(randint(0, 100))
})
Step 5
Now letβs be sure to label our Love Machine! Use the basic ||basic:show string|| function to show the message βLOVE METERβ on the screen of the micro:bit.
basic.showString("LOVE METER")
input.onPinPressed(TouchPin.P0, function() {
basic.showNumber(randint(0, 100));
})
Step 6
Letβs test our code. Press Pin 0 on the micro:bit on-screen simulator (bottom left). Numbers between 0-25 = π€ No Love, 26-50 = π«Ά BFF Love, 51-75 = π Brokenhearted Love, 76-100 = ππ₯ Fiery Hot Love!
Step 7
If you have a micro:bit device, connect it to your computer and click the |Download| button. Follow the instructions to transfer your code onto the micro:bit. Once your code has been downloaded, hold the GND pin with one hand and touch the 0 pin with the other hand. Your micro:bit π LOVE METER π machine will detect the love current flowing through your body!